﻿namespace Acoris.Rendering
{
#if WIN2D
    using Microsoft.Graphics.Canvas.Geometry;
#endif

    /// <summary>
    /// 
    /// </summary>
    class StrokeStyleHelper
    {
#if WIN2D
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strokeStyle"></param>
        /// <returns></returns>
        public static CanvasStrokeStyle GetStrokeStyle(StrokeStyle strokeStyle)
        {
            return new CanvasStrokeStyle
            {
                LineJoin = GetLineJoin(strokeStyle.LineJoin),
                DashStyle = GetDashStyle(strokeStyle.DashStyle),
                StartCap = GetCapStyle(strokeStyle.StartCap),
                DashCap = GetCapStyle(strokeStyle.DashCapStyle),
                EndCap = GetCapStyle(strokeStyle.EndCap),
                DashOffset = strokeStyle.DashOffset,                
            };
        }

        internal static CanvasLineJoin GetLineJoin(LineJoin lineJoin)
        {
            switch (lineJoin)
            {
                case LineJoin.Bevel:
                    return CanvasLineJoin.Bevel;
                case LineJoin.Miter:
                    return CanvasLineJoin.Miter;
                case LineJoin.MiterOrBevel:
                    return CanvasLineJoin.MiterOrBevel;
                case LineJoin.Round:
                    return CanvasLineJoin.Round;
                default:
                    return CanvasLineJoin.Bevel;
            }
        }

        internal static CanvasDashStyle GetDashStyle(DashStyle dashStyle)
        {
            switch (dashStyle)
            {
                case DashStyle.Dash:
                    return CanvasDashStyle.Dash;
                case DashStyle.DashDot:
                    return CanvasDashStyle.DashDot;
                case DashStyle.DashDotDot:
                    return CanvasDashStyle.DashDotDot;
                case DashStyle.Dot:
                    return CanvasDashStyle.Dot;
                case DashStyle.Solid:
                    return CanvasDashStyle.Solid;
                default:
                    return CanvasDashStyle.Solid;
            }
        }

        internal static CanvasCapStyle GetCapStyle(CapStyle capStyle)
        {
            switch (capStyle)
            {
                case CapStyle.Flat:
                    return CanvasCapStyle.Flat;
                case CapStyle.Round:
                    return CanvasCapStyle.Round;
                case CapStyle.Square:
                    return CanvasCapStyle.Square;
                case CapStyle.Triangle:
                    return CanvasCapStyle.Triangle;
                default:
                    return CanvasCapStyle.Flat;
            }
        }
#endif
    }
}
